package web;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import service.PublishService;
import util.web.ServletUtil;

public class AddPublish extends HttpServlet {

	
	
	private static final long serialVersionUID = 1L;


	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		ServletUtil.forware(request, response, "admin/addpublish");
		
	}

	
	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		PublishService publishService = new PublishService();
		String publishName = request.getParameter("publishname");
		boolean b = publishService.addPublish(publishName);
		if (b) {
			ServletUtil.sendRedirect(response, "/admin/publishlist.jspx");
		}else {
			ServletUtil.sendRedirect(response, "/admin/addpublish.jspx?state=1001");
		}
	}

	
	
	
	
	
	
}
